//模拟map
// const map = (array, fn) => {
//     let results = [];
//     for(let value of array){
//         results.push(fn(value))
//     }
//     return results
// }

// let arr = [1, 2, 3, 4]
// arr = map(arr, v => v * v)
// console.log(arr)

//模拟 every
// const every = (array, fn) => {
//     let result = true
//     for(let value of array){
//         result = fn(value)
//         if(!result){
//             break
//         }
//     }
//     return result
// }

// let arr = [11, 22, 34, 33, 45]
// let r = every(arr, v => v > 10)
// console.log(r)

//模拟some
const some = (array, fn) => {
    let result = false
    for(value of array){
        result = fn(value)
        if(result){
            break
        }
    }
    return result
}

let arr = [2, 8, 4, 5, 7]
let s = some(arr, v => v % 3 === 0)
console.log(s);